version: '3'

services:
#  my-app:
#    image: front-mqh/my-app
#    build:
#      context: ./my-app
#      dockerfile: Dockerfile
#    container_name: front-mqh-app
#    networks:
#      - lab8net
#    ports:
#      - 3000:3000


  database:
    image: postgresql
    build:
      context: ./database
      dockerfile: Dockerfile
    container_name: database
    ports:
      - "5432:5432"
    restart: always
    networks:
      - lab8net
    environment:
#      - PGUSER=dbuser
      - POSTGRES_USER=dbuser
      - POSTGRES_PASSWORD=1357924680d
      - POSTGRES_HOST=localhost
      - POSTGRES_DATABASE=mqh_db
#      - PGDATABASE=MQH_db
#      - MYSQL_ROOT_PASSWORD=root
    volumes:
      - dbvolume:/var/lib/postgresql
    healthcheck:
      test: [ "CMD", "curl", "-f", "http://localhost:5432" ]
      interval: 30s
      timeout: 10s
      retries: 5

  MQH:
    image: back-mqh/mqh-app
    command: python manage.py runserver 0.0.0.0:8000
    #      - python manage.py migrate
    build:
      context: ./MQH
      dockerfile: Dockerfile
    #    entrypoint: ./entrypoint.sh
    container_name: mqh-backend
    networks:
      - lab8net
    ports:
      - 8000:8000
    #    environment:
    #      - APP_SERVICE_NAME=shop100-backend
    volumes:
      - backendvolume:/MQH
#      - /tmp/shop100/mysqld:/run/mysqld
    #    volumes:
    #      - .:/backend
    restart: on-failure
    depends_on:
      - database
    links:
      - database
#        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000"]
      interval: 30s
      timeout: 10s
      retries: 5

networks:
  lab8net:

volumes:
  backendvolume:
  dbvolume: